<!DOCTYPE html>
<html lang="zh-CN">
<head><!--头部-->
    <meta charset="utf-8">
    <meta name="keywords" content="关键词">
    <meta name="description" content="站点描述"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,user-scalable=no">
    <title>运营商</title>
    <link href="css/main.css" rel="stylesheet">
    <script src="js/rem.js"></script>
    <script src="js/jquery-3.1.js"></script>
</head>
<body style="visibility:hidden;">
<div class="header-title header-title2"><!--标题-->
    <a href="javascript:history.back()" class="back"></a>
    <p class="title">个人信息</p>
</div>
<div class="main-cont"><!--内容 begin-->
    <div class="buzhou"><!--步骤123-->
        <div class="line line2"><em></em></div>
        <ul>
            <li class="active">
                <span>1</span>
                <p>个人信息</p>
            </li>
            <li class="active">
                <span>2</span>
                <p>运营商</p>
            </li>
 <!--           <li>
                <span>3</span>
                <p>京东</p>
            </li>-->
        </ul>
    </div><!--步骤123 end-->
    <p class="shuoming">填写运营商信息</p>
    <div class="tel-info"><!--运营商信息-->
        <div class="input-box">
            <span>您的手机号</span>
            <input type="text" id="phone" placeholder="请输入您的手机号" maxlength="11" class="phone"/>
        </div>
        <div class="input-box">
            <span>所属运营商</span>
            <input type="text" readonly="readonly" class="yys"/>
        </div>
        <div class="input-box">
            <span>服务密码</span>
            <input type="password" id="passwd" placeholder="运营商的服务密码"/>
        </div>

        <div id="authCodeImgDiv"><img id="authCodeImg" src=""></div>

        <div class="input-box" id="submitTxtDiv" style="display: none">
            <span>验证码</span>
            <input type="text" id="submitTxt" placeholder="短信或图片验证码"/>
        </div>
    </div><!--运营商信息 end-->
    <div class="next-btn"><!--下一步按钮-->
        <input type="button" onclick="nextStep()" class="btn" value="下一步"/>
        <p class="yinhang"><em></em>银行级数据加密保护</p>
        <div class="text">
            <p>
                温馨提示:<br>
                1.服务密码是指办理手机卡时设置得到数字密码，通常用于办理和查询营业厅业务的服务密码；<br>
                2.如果您忘记密码，建议您拨打运营客服电话或本人前往营业2厅重置密码，重置密码需要验证开卡身份证<br>
            </p>
        </div>
    </div>
</div><!--内容end-->
<script type="text/javascript" src="js/core.js"></script>
<script>

    $(function () {

        //1毫秒后显示页面
        setTimeout(showPage, 1);

        function showPage() {
            $('body').css({'visibility': 'visible'})
        }

        //页面高度
        var winHh = $(window).height()
        $('.main-cont').css({'minHeight': winHh})
        //运营商判断

        $('.tel-info .phone').bind('input propertychange', function () {
            var phone = $('.tel-info .phone').val();
            if (phone.length == 11) {
                if (CMCC.test(phone)) {
                    $('.tel-info .yys').val('中国移动')
                }
                else if (CUCC.test(phone)) {
                    $('.tel-info .yys').val('中国联通')
                }
                else if (CTCC.test(phone)) {
                    $('.tel-info .yys').val('中国电信')
                }
                else {
                    $('.tel-info .yys').val('')
                    alert('请输入正确的手机号码')
                }
            }
        });
    });



    var tag = true;//是否走第一步验证
    var userId = getvl("userId");//用户id
    var phoneNo;//手机号
    var passwd;//服务密码
    var taskId;//任务id
    var code;//返回码
    var nextStage="";//下一步请求所处阶段，如 初始"INIT",提交"SUBMIT",查询"QUERY"
    var ss = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAABIAAAASABGyWs+AAALZklEQVRYwyWX229l10GHv7X22nufq8/Nx8eX2M7Y08nMxElmkk4uLUGomZakqKBU7QN9AJU+RFRAhbiIixBqQdxUpS8gISGRFqlqKYRCUkRIWiAhVZg01ybNTGYmtmdsj+2xfexz3XuvvS48zL/wSd9P309N31PzMhL4RCKkI2pB3KsRaonOMyYn69SaZXSqSUY5yTgn1ZrSiRo6HdBczpm+dwbRy9lZ26Jsl4jDAkEkqJdOYHRELarw9oUXMTojHWUMRxkmNxTjCFWsScgVtmrw3oOVDMuHtFyLggjYH4yYmC6gMo/zjkBYFpbK+Ipj/Zqncq5K7+CIipIUgim6WwnTp3LMThk1IXj4nof46z//Y1SxSCACpHCUSjHp0FCdmkMFw5BEayaaNWzN0L/Uw92msc2U436Z691Nkm5OJcyJhSOUnsMdw+ULe7hxz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HuIRS5QwfWjrAWIUMbse5HCkDEB5nHUEQYn1CVK3xzD98jVf+8Unu+9in+MaLT3H9xh63taZxyoL1qEo5JJIC7Q1SCcIwxAcBw/ER+/0h693rLPiHyLzHeo81mkpphVa0iJRlICFJc7wQt46NyW/REoLUOR56/Fd4/+kn+da/PMmmGXPqthNYYRiN+oRRgf8HOlLxDG5bfLEAAAAldEVYdGRhdGU6Y3JlYXRlADIwMTUtMDgtMTdUMDA6MjA6MTEtMDQ6MDAphEAdAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE1LTA4LTE3VDAwOjIwOjExLTA0OjAwWNn4oQAAAE10RVh0c29mdHdhcmUASW1hZ2VNYWdpY2sgNi41LjQtNyAyMDEyLTA1LTA5IFExNiBPcGVuTVAgaHR0cDovL3d3dy5pbWFnZW1hZ2ljay5vcmen81WCAAAAGHRFWHRUaHVtYjo6RG9jdW1lbnQ6OlBhZ2VzADGn/7svAAAAGHRFWHRUaHVtYjo6SW1hZ2U6OmhlaWdodAAyNTamnkfJAAAAF3RFWHRUaHVtYjo6SW1hZ2U6OldpZHRoADI1NnoyFEQAAAAZdEVYdFRodW1iOjpNaW1ldHlwZQBpbWFnZS9wbmc/slZOAAAAF3RFWHRUaHVtYjo6TVRpbWUAMTQzOTc4NTIxMUDdSycAAAARdEVYdFRodW1iOjpTaXplADEyMmtiVWh0cgAAACp0RVh0VGh1bWI6OlVSSQBmaWxlOi8vLy90bXAvL29yaWdpbmFsL2tDOFNEWzBdO33n4QAAAABJRU5ErkJggg==";

    var authCode;

    //    $("#authCodeImg").attr("src", "data:image/png;base64," + ss);


    function nextStep() {
        if (tag) {
            phoneNo = $("#phone").val();
            passwd = $("#passwd").val();
            if (phoneNo == "" || passwd == "") {
                alert("手机号或服务密码不能为空");
                return;
            }
            var mobileAuth1 = {
                userId: userId,
                phoneNo: phoneNo,
                passwd: passwd
            };
            //第一步
            $.ajax({
                type: "GET",
                url: urlcore + "/api/user/mobileAuth1",
                dataType: "json",
                async: false,
                contentType: "application/json;charset=UTF-8",
                data: mobileAuth1,
                success: function (data) {
                    console.log("第一步验证返回：",data.data);
                    var cbdata = data.data;
                    tag = false;//不再走第一步验证
                    code = cbdata.code;
                    taskId = cbdata.taskId;
                    if(cbdata.nextStage!=undefined){
                        nextStage = cbdata.nextStage;
                    }
                    if (code == 100 || code == 101 || code == 105 || code == 137 || code == 2007) {

                        if (code == 100) {
                            alert("正在处理，请等待");
                            //任务正在处理,请稍后查询结果
                        } else if (code == 101) {
                            //请输入图片验证码

                        } else if (code == 105) {
                            //请输入手机验证码

                        } else if (code == 137 || code == 2007) {
                            //完成
                        }
                        mobileAuth2();//第二步验证
                    } else {
                        alert(data.data.message);
                        window.location.reload();
                    }
                },
                error: function () {
                    alert("error")
                }
            });
        } else {
            mobileAuth2();
        }

    }


    //定时轮询
//    var pullTag = true;//轮询tag
    //第二步验证
    function mobileAuth2() {
        var txt = $("#submitTxt").val();
        var mobileAuth2 = {
            taskId: taskId,
            passwd: passwd,
            nextStage: nextStage,
            code: code,
            txt: txt,
            phoneNo: phoneNo,
            userId:userId
        };
//        setTimeout("showTime()",2000);
        //第二步
        $.ajax({
            type: "GET",
            url: urlcore + "/api/user/mobileAuth2",
            dataType: "json",
            async: false,
            contentType: "application/json;charset=UTF-8",
            data: mobileAuth2,
            success: function (data) {
                console.log("第二步验证返回：", data.data);
                var cbdata = data.data;
                code = cbdata.code;
                nextStage = cbdata.nextStage;
                if (code == 100 || code == 101 || code == 105 || code == 137 || code == 2007) {
                    if (code == 100) {
                        //任务正在处理,请稍后查询结果,轮询第二步 查询
                        setTimeout("mobileAuth2()", 2000);
                    } else if (code == 101) {
                        //请输入图片验证码
                        $("#submitTxt").val("");
                        authCode = cbdata.authCode;
                        $("#authCodeImgDiv").show();
                        $("#authCodeImg").attr("src", "data:image/png;base64," + authCode);
                        $("#submitTxtDiv").show();
                    } else if (code == 105) {
                        $("#submitTxt").val("");
                        $("#authCodeImgDiv").hide();
                        alert("短信验证码已发送");
                        if(!CUCC.test(phoneNo)){
                            $("#submitTxtDiv").show();
                        }
                        //请输入手机验证码
                        $("#authCodeImg").attr("src", "");
                    } else if (code == 137 || code == 2007) {
                        //完成
                        goNext();
                    }
                } else {
                    alert(data.data.message);
                    window.location.reload();
                }

            },
            error: function () {
                alert("error")
            }
        });
    }

/*    function goNext() {
        alert("运营商认证通过!");
        window.location.href = "page3.html?userId="+userId;
    }*/

    function goNext() {
        alert("运营商认证通过!");
        window.location.href = "index1.html?auth=1&userId="+userId;
    }
</script>

</body>
</html>
